How to read Config.property file save in Internal Storage manually
Properties prop=new Properties();
String filePath = getFilesDir() + "/Myfolder/" + "config.properties";
File yourFile = new File(filePath);
Log.d("yourFile",""+yourFile);
try {
InputStream in = new FileInputStream(""+yourFile);
prop.load(in);
String readData=prop.getProperty("database");
Log.d("readData",readData);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
I create a config file and put it into Phone internal storage I want to read this file when i am trying to read its showing filenotfound exception how to read this file please help me.
java android
add a comment |
Properties prop=new Properties();
String filePath = getFilesDir() + "/Myfolder/" + "config.properties";
File yourFile = new File(filePath);
Log.d("yourFile",""+yourFile);
try {
InputStream in = new FileInputStream(""+yourFile);
prop.load(in);
String readData=prop.getProperty("database");
Log.d("readData",readData);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
I create a config file and put it into Phone internal storage I want to read this file when i am trying to read its showing filenotfound exception how to read this file please help me.
java android
add a comment |
Properties prop=new Properties();
String filePath = getFilesDir() + "/Myfolder/" + "config.properties";
File yourFile = new File(filePath);
Log.d("yourFile",""+yourFile);
try {
InputStream in = new FileInputStream(""+yourFile);
prop.load(in);
String readData=prop.getProperty("database");
Log.d("readData",readData);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
I create a config file and put it into Phone internal storage I want to read this file when i am trying to read its showing filenotfound exception how to read this file please help me.
java android
Properties prop=new Properties();
String filePath = getFilesDir() + "/Myfolder/" + "config.properties";
File yourFile = new File(filePath);
Log.d("yourFile",""+yourFile);
try {
InputStream in = new FileInputStream(""+yourFile);
prop.load(in);
String readData=prop.getProperty("database");
Log.d("readData",readData);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
I create a config file and put it into Phone internal storage I want to read this file when i am trying to read its showing filenotfound exception how to read this file please help me.
java android
java android
asked Nov 15 '18 at 10:12
sanjeev kumarsanjeev kumar
251214
251214
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The path you put the file is wrong. GetFiledirectory is the path that can not be accessed through mobile file. You should creat file in that directory first and then to write data inside it.
In other words, you are putting file in external directory and want to read it from internal directory.
Internal Storage
Files are accessible by only your app
Files are removed when your app is uninstalled
Files are always available (meaning they files will never be saved on a removable memory)
External Storage
Files are fully readable by other apps (including any variant of File Manager app, in your case)
Files aren't necessarily removed when your app is uninstalled - explained later
Files availability isn't guaranteed (can be deleted by other apps / removable memory).
You can either specified path of file in sdcard for reading file located in external directory or create file programmically inside internal directory following what you have done in the code.
Since you are going to create file before installing app, you can specifying path of the external storage like below
String path = Environment.getExternalStorageDirectory+ "/Myfolder/" + "config.properties";
i have to add first manually config file in android phone, then i have to read that file from application.
– sanjeev kumar
Nov 15 '18 at 10:35
Its working bro Thanks for information.
– sanjeev kumar
Nov 15 '18 at 11:41
i have up voted your answer too nice information.
– sanjeev kumar
Nov 15 '18 at 11:42
1
if you like the question please upvote thanks in advance.
– sanjeev kumar
Nov 15 '18 at 11:44
I am glad that my answer was helpful for you. Thank you
– Amir
Nov 15 '18 at 11:46
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317040%2fhow-to-read-config-property-file-save-in-internal-storage-manually%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The path you put the file is wrong. GetFiledirectory is the path that can not be accessed through mobile file. You should creat file in that directory first and then to write data inside it.
In other words, you are putting file in external directory and want to read it from internal directory.
Internal Storage
Files are accessible by only your app
Files are removed when your app is uninstalled
Files are always available (meaning they files will never be saved on a removable memory)
External Storage
Files are fully readable by other apps (including any variant of File Manager app, in your case)
Files aren't necessarily removed when your app is uninstalled - explained later
Files availability isn't guaranteed (can be deleted by other apps / removable memory).
You can either specified path of file in sdcard for reading file located in external directory or create file programmically inside internal directory following what you have done in the code.
Since you are going to create file before installing app, you can specifying path of the external storage like below
String path = Environment.getExternalStorageDirectory+ "/Myfolder/" + "config.properties";
i have to add first manually config file in android phone, then i have to read that file from application.
– sanjeev kumar
Nov 15 '18 at 10:35
Its working bro Thanks for information.
– sanjeev kumar
Nov 15 '18 at 11:41
i have up voted your answer too nice information.
– sanjeev kumar
Nov 15 '18 at 11:42
1
if you like the question please upvote thanks in advance.
– sanjeev kumar
Nov 15 '18 at 11:44
I am glad that my answer was helpful for you. Thank you
– Amir
Nov 15 '18 at 11:46
add a comment |
The path you put the file is wrong. GetFiledirectory is the path that can not be accessed through mobile file. You should creat file in that directory first and then to write data inside it.
In other words, you are putting file in external directory and want to read it from internal directory.
Internal Storage
Files are accessible by only your app
Files are removed when your app is uninstalled
Files are always available (meaning they files will never be saved on a removable memory)
External Storage
Files are fully readable by other apps (including any variant of File Manager app, in your case)
Files aren't necessarily removed when your app is uninstalled - explained later
Files availability isn't guaranteed (can be deleted by other apps / removable memory).
You can either specified path of file in sdcard for reading file located in external directory or create file programmically inside internal directory following what you have done in the code.
Since you are going to create file before installing app, you can specifying path of the external storage like below
String path = Environment.getExternalStorageDirectory+ "/Myfolder/" + "config.properties";
i have to add first manually config file in android phone, then i have to read that file from application.
– sanjeev kumar
Nov 15 '18 at 10:35
Its working bro Thanks for information.
– sanjeev kumar
Nov 15 '18 at 11:41
i have up voted your answer too nice information.
– sanjeev kumar
Nov 15 '18 at 11:42
1
if you like the question please upvote thanks in advance.
– sanjeev kumar
Nov 15 '18 at 11:44
I am glad that my answer was helpful for you. Thank you
– Amir
Nov 15 '18 at 11:46
add a comment |
The path you put the file is wrong. GetFiledirectory is the path that can not be accessed through mobile file. You should creat file in that directory first and then to write data inside it.
In other words, you are putting file in external directory and want to read it from internal directory.
Internal Storage
Files are accessible by only your app
Files are removed when your app is uninstalled
Files are always available (meaning they files will never be saved on a removable memory)
External Storage
Files are fully readable by other apps (including any variant of File Manager app, in your case)
Files aren't necessarily removed when your app is uninstalled - explained later
Files availability isn't guaranteed (can be deleted by other apps / removable memory).
You can either specified path of file in sdcard for reading file located in external directory or create file programmically inside internal directory following what you have done in the code.
Since you are going to create file before installing app, you can specifying path of the external storage like below
String path = Environment.getExternalStorageDirectory+ "/Myfolder/" + "config.properties";
The path you put the file is wrong. GetFiledirectory is the path that can not be accessed through mobile file. You should creat file in that directory first and then to write data inside it.
In other words, you are putting file in external directory and want to read it from internal directory.
Internal Storage
Files are accessible by only your app
Files are removed when your app is uninstalled
Files are always available (meaning they files will never be saved on a removable memory)
External Storage
Files are fully readable by other apps (including any variant of File Manager app, in your case)
Files aren't necessarily removed when your app is uninstalled - explained later
Files availability isn't guaranteed (can be deleted by other apps / removable memory).
You can either specified path of file in sdcard for reading file located in external directory or create file programmically inside internal directory following what you have done in the code.
Since you are going to create file before installing app, you can specifying path of the external storage like below
String path = Environment.getExternalStorageDirectory+ "/Myfolder/" + "config.properties";
edited Nov 15 '18 at 11:05
answered Nov 15 '18 at 10:23
AmirAmir
161214
161214
i have to add first manually config file in android phone, then i have to read that file from application.
– sanjeev kumar
Nov 15 '18 at 10:35
Its working bro Thanks for information.
– sanjeev kumar
Nov 15 '18 at 11:41
i have up voted your answer too nice information.
– sanjeev kumar
Nov 15 '18 at 11:42
1
if you like the question please upvote thanks in advance.
– sanjeev kumar
Nov 15 '18 at 11:44
I am glad that my answer was helpful for you. Thank you
– Amir
Nov 15 '18 at 11:46
add a comment |
i have to add first manually config file in android phone, then i have to read that file from application.
– sanjeev kumar
Nov 15 '18 at 10:35
Its working bro Thanks for information.
– sanjeev kumar
Nov 15 '18 at 11:41
i have up voted your answer too nice information.
– sanjeev kumar
Nov 15 '18 at 11:42
1
if you like the question please upvote thanks in advance.
– sanjeev kumar
Nov 15 '18 at 11:44
I am glad that my answer was helpful for you. Thank you
– Amir
Nov 15 '18 at 11:46
i have to add first manually config file in android phone, then i have to read that file from application.
– sanjeev kumar
Nov 15 '18 at 10:35
i have to add first manually config file in android phone, then i have to read that file from application.
– sanjeev kumar
Nov 15 '18 at 10:35
Its working bro Thanks for information.
– sanjeev kumar
Nov 15 '18 at 11:41
Its working bro Thanks for information.
– sanjeev kumar
Nov 15 '18 at 11:41
i have up voted your answer too nice information.
– sanjeev kumar
Nov 15 '18 at 11:42
i have up voted your answer too nice information.
– sanjeev kumar
Nov 15 '18 at 11:42
1
1
if you like the question please upvote thanks in advance.
– sanjeev kumar
Nov 15 '18 at 11:44
if you like the question please upvote thanks in advance.
– sanjeev kumar
Nov 15 '18 at 11:44
I am glad that my answer was helpful for you. Thank you
– Amir
Nov 15 '18 at 11:46
I am glad that my answer was helpful for you. Thank you
– Amir
Nov 15 '18 at 11:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317040%2fhow-to-read-config-property-file-save-in-internal-storage-manually%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown