where can I upload json file?

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

Answers (5)

Zohaib Brohi
Zohaib Brohi

Reputation: 574

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.

Upvotes: 1

Force Bolt
Force Bolt

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

Viral Patel
Viral Patel

Reputation: 33438

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.

Upvotes: 0

Athul
Athul

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

Akshay Panchal
Akshay Panchal

Reputation: 695

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

Upvotes: 0

Related Questions