3

My Android app has raw files in resource folder from which I retrieve data that is crucial to my app.

These resource files needs to be updated from time to time if not often.

Is there a way to achieve this through Google update mechanism (Developer console or any other tool) ?

I'm aware that Google's new policy doesn't allow updating apps through non-Playstore sources. Google's new policy

Most of the time I need to update only this particular file and most of the code remains same (unless there are bugs).

I feel it's redundant to make the user download the entire .apk file just to update a single raw file.

Vivo
  • 768
  • 1
  • 8
  • 20

1 Answers1

2

No its not possible and you shouldn't design an app like this.

I can see what you want, you want to download something from server to client without blocking the UI.

Build an api using some server side language that returns the file you want if only the file in remote has been updated(you can do a datetime comparison between client and server and if its different then download it)

You can try asynctask make a api call which returns the file you want and save it in the resource folder.

Here is a sample asynctask

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.Settings.System;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.view.View.OnClickListener;

public class AsyncTaskActivity extends Activity implements OnClickListener {

    Button btn;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btn = (Button) findViewById(R.id.button1);
        // because we implement OnClickListener we only have to pass "this"
        // (much easier)
        btn.setOnClickListener(this);
    }

    public void onClick(View view) {
        // detect the view that was "clicked"
        switch (view.getId()) {
        case R.id.button1:
            new LongOperation().execute("");
            break;
        }
    }

    private class LongOperation extends AsyncTask<String, Void, String> {

        @Override
        protected String doInBackground(String... params) {
            for (int i = 0; i < 5; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    Thread.interrupted();
                }
            }
            return "Executed";
        }

        @Override
        protected void onPostExecute(String result) {
            TextView txt = (TextView) findViewById(R.id.output);
            txt.setText("Executed"); // txt.setText(result);
            // might want to change "executed" for the returned string passed
            // into onPostExecute() but that is upto you
        }

        @Override
        protected void onPreExecute() {}
    }
}

I hope this clears your problem

Vivo
  • 768
  • 1
  • 8
  • 20
  • NO. I'm aware of how to use threads in Android. Updating through a server is one of the ways but how can I use that particular file in my app. During development, I place files like that in a resource->raw->file.f Once the app is deployed, where is this resource folder going to be? – Sreecharan Desabattula Jul 26 '14 at 20:19
  • @SreecharanDesabattula you can't write to resources directory – Vivo Jul 28 '14 at 16:36
  • Like I pointed out, I need some way to update a file from the app and the file is supposed to be private to the app. Not necessarily resource directory. Thanks! – Sreecharan Desabattula Jul 29 '14 at 19:53