0

I am using a source for image loading from url. The image links are stored in a json file and the json file to be hosted in a server. But I want the json file to store locally may be in assets or drawable. My problem is if i use asset manager, it has to use stream manager and stream manager does not sit with url, which is realated with a context to load image url. If i change the url of config_wallpaper_manifest_url to loacal asset url, ie. example.json, the same never loads. what would be the possible solution for this? thanks.

public void loadData (Bundle savedInstanceState) {

    // Check Network State
    if (!NetworkUtil.getNetworkState(this)) {
        final RetryFragment fragment = RetryFragment.getFragmentWithMessage("No connection");
        this.addFragment(fragment, RetryFragment.TAG, true);
        return;
    }



    if (savedInstanceState == null || savedInstanceState.get(KEY_LIST_DATA) == null) {
        final String url = super.getResources().getString(R.string.config_wallpaper_manifest_url);
        if (url != null && URLUtil.isValidUrl(url)) {
            // Add Loading Fragment
            final LoadingFragment fragment = new LoadingFragment();
            this.addFragment(fragment, LoadingFragment.TAG, true);

            // Load Data
            final RestClientHandler handler = new RestClientHandler(this);
            RestClient.get(this, url, handler);
        }

    } else {
        Log.i(TAG, "Restored Instance");
        this.mData = (ArrayList<NodeCategory>) savedInstanceState.get(KEY_LIST_DATA);
        this.mPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        if (this.mPosition != -1) {
            mIgnoreSelection = true;
        }

        this.configureActionBar();
    }
}
morten.c
  • 3,414
  • 5
  • 40
  • 45

1 Answers1

0

JSON is basically text. store it in app's internal memory. Or in a SQLite database. Have a look at this:

Creating folder in internal Memory to save files and retrieve them later

Community
  • 1
  • 1
shiladitya
  • 2,290
  • 1
  • 23
  • 36