2

I have a package that contains two files one java file that is a SyncAdapterTest and another file which is a json file.

I am following the same structure as the SyncAdapterTest in the sample app in the Android website. http://developer.android.com/shareables/training/BasicSyncAdapter.zip. With one exception rather than having a String variable with json assigned to it directly, I'd rather have the json in a seperate file as its too large and it makes the test unreadable, plus reusability.

I am pretty new to Android development and I have tried using File or InputStream in = getClass().getResourceAsStream("sample.json"). I keep getting the InputStream null and the File.exists() as false. Is there something obvious that I am missing?

Here is my code

public void testIncomingParsed() {
        InputStream in = getClass().getResourceAsStream("sample.json");
        if (in != null) {
            Log.d("HOMERSIMPSON", "wooohoo");
            Log.d("HOMERSIMPSON", in.toString());
        } else {
            Log.d("HOMERSIMPSON", "dooooooooooh");
        }
    }

As you can imagine doooooh! is what I'm getting.

a.ajwani
  • 868
  • 1
  • 8
  • 21

0 Answers0