1

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

5 Answers5

1

There are 2 ways you can do that:

  1. Local Storage: You can save a JSON file in your project locally. (already answered by others)
  2. Upload your JSON: You can upload your JSON at jsonbin.io and it will generate an API that you can use in your project.
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Zohaib Brohi
  • 576
  • 1
  • 7
  • 15
0

You can store JSON file in your assets folder......

Akshay Panchal
  • 695
  • 5
  • 15
0
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

Athul
  • 801
  • 7
  • 16
0

Based on your requirement:

  1. Best option is to host it on a (web server if you have one)
  2. If you don't, share the file on GDrive or Dropbox (or similar hosting services which provide free storage). Share it with read-only access for your app to read from.
Viral Patel
  • 32,418
  • 18
  • 82
  • 110
0

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.

Force Bolt
  • 1,117
  • 9
  • 9