Alex Rivera | Logout

Include local .json file in Eclipse Android project

Asked 2011-08-18T14:47:50.943
14

I have a local .json file. I don't want it to be on a server, I just want it to be included in my app. I tried to paste it directly into Eclipse in my project, but I got a FileNotFoundException, I also tried to paste it in the workspace folder in Windows Explorer/Finder and got the same exception. Where should I put it?

Thanks!

Edit
Report

1 Answer

30

You should put the file either in the /assets or /res/raw directory of your Android project. From there, you can retrieve it with either: Context.getResources().openRawResource(R.raw.filename) or Context.getResources().getAssets().open("filename").

answered 2011-08-18T14:54:07.523

Your Answer