1
It is possible to create and remove files .properties
of Android
, by the application itself?
Ex: after creating an annotation it creates a file .properties
with the name of that note!
1
It is possible to create and remove files .properties
of Android
, by the application itself?
Ex: after creating an annotation it creates a file .properties
with the name of that note!
1
Cannot create files from the application. You can however interact with an existing file. To this end you should:
Create in your project, at the desired location the file you will use from the application.
After the created file, you can use a function like the one shown below to store data in it:
public void CreatePropertiesFile(Context context) {
Properties prop = new Properties();
String propertiesPath = context.getFilesDir().getPath().toString() + "/app.properties";
try {
FileOutputStream out = new FileOutputStream(propertiesPath);
prop.setProperty("HomeVersion", "0");
prop.setProperty("DatePlaySquare", "0");
prop.setProperty("CustomerID", "0");
prop.setProperty("DeviceToken", "0");
prop.setProperty("CurrentVersionMobile", "0");
prop.setProperty("Domain", "Megazy");
prop.setProperty("DownloadNewVersion","0");
prop.store(out, null);
out.close();
} catch (IOException e) {
System.err.println("Failed to open app.properties file");
e.printStackTrace();
}
}
You must adapt the function to your needs, but you already have an idea of how you can perform the operation.
This is just an example taken from of this answer on the SOEN placed by using @user3113670.
Another good example can be found in this answer also in the SOEN placed by the user @Javanator.
On Android, when we talk about saving data, we almost always talk about Data Storage more specifically Shared Preferences. There is a very good tutorial on this subject:
Credits of this information to the user @Rajesh in this answer in the SOEN that evidenced the links to the documentation and tutorial.
Browser other questions tagged android filing-cabinet
You are not signed in. Login or sign up in order to post.