Reputation: 51
I have wrote a json file with data I will get it to recycleview in android but I don't know where can I upload this file to access it into android project
Upvotes: 1
Views: 10770
Reputation: 574
There are 2 ways you can do that:
Upvotes: 1
Reputation: 1221
You can put your json file in the assets folder and best option is host the json file on the server and use the data (API) in your project.
Upvotes: 0
Reputation: 33438
Based on your requirement:
Upvotes: 0
Reputation: 821
void saveStringToFile(String path, String content) {
try {
File newFile = new File(path);
newFile.createNewFile();
FileOutputStream fos = new FileOutputStream(newFile);
fos.write(content.getBytes());
fos.flush();
fos.close();
Constant.logD("File "+ newFile.getName()+ " is saved successfully at "+ newFile.getAbsolutePath());
} catch (Exception e) {
Constant.logE("Unable to save file", e);
}
}
Mention a path in a mobile sdcard like Environment.getExternalStorageDirectory().getAbsolutePath()+"/" + System.currentTimeMillis()+".jpg" as path
Upvotes: 0