Q: Best way for application folder design for android (packages)

409 views
Skip to first unread message

Carsten Thielepape

unread,
Feb 4, 2013, 10:08:23 AM2/4/13
to kivy-...@googlegroups.com
Hello all,
 
I am developing an application (Remote control with a tablet) using kivy. As part of the application, there will be section of user data (eg remote control codes, further interfaces in python code) , which the user has to copy to the application folder to use them. And there is a set of core application data as well (skins, other xml files) which might be updated which a new version.So I need folder/installation structure, which:
 
  • Can be installed by an apk pakage (program files and application data)
  • A user can add further files into it
    • Further files can includes python code, which will be loaded at runtime!
  • User added data will not be removed by an application update 
  • Application data will be updated by an application update
Currently, I am creating the apk with the core program files only, and a separate zip with application data, which needs to be copied to a sdcard folder.This application data folder can be safely extended by user files.  (same as kivy launcher, works). But this means, that I would not be able to lauch the app on the google play, as half of the app is missing.
 
Does someone got an idea, how to design and package this?
 
Greetings.
 
Carsten
 
 
 

Richard Jones

unread,
Feb 4, 2013, 7:47:33 PM2/4/13
to kivy-...@googlegroups.com
I'm not 100% sure but I've run into a similar problem with user data being removed during update. I *think* the only solution is to store it on the sdcard, separate from the usual user data storage.

I *think* that the new /storage/emulated/... filesystem structure is supposed to solve this issue, but I'm not certain. I've not found any information anywhere regarding the storage of user data and how it should persist across apk upgrades :-(


     Richard

Petr Vanek

unread,
Feb 5, 2013, 4:53:01 PM2/5/13
to kivy-...@googlegroups.com
Hi,

just tested in kivy shell (default home is /storage/emulated/0/org.kivy.sshshell):

>>> print os.getcwd()
/storage/emulated/0/org.kivy.sshshell
>>> os.makedirs('/storage/emulated/0/petr')
>>> os.chdir('/storage/emulated/0/petr')
>>> print os.getcwd()
/storage/emulated/0/petr

>>> f = open('test.txt','w')
>>> f.write(str('my text'))
>>> f.close()
>>> print os.listdir('./')
['test.txt']

so it seems you can make permanent storage in the home sd card.

would this work in older android devices?

Petr

Richard Jones

unread,
Feb 5, 2013, 10:11:34 PM2/5/13
to kivy-...@googlegroups.com, python-fo...@googlegroups.com
[cc'ing the python-for-android project as this affects them too]

I've just done an upgrade of my application and the existing save game
data in /storage/emulated/0/... was lost. AGH.

So, according to
http://developer.android.com/guide/topics/data/data-storage.html we
need to have a better solution for this.

For my application I need to store a smallish amount of data. I
*think* I would actually be able to get away with storing it in the
"Shared Preferences".

I believe that's where the kivy config should be stored by default.

Nothing I've read about the Internal Storage says anything about file
persistence across upgrades. They do explicitly say that files are
removed when the application is removed. I really wish I knew what
Kivy was doing differently that resulted in the files being removed
across upgrades (even reinstalls of the same *version*.)

Regardless, we shouldn't be using the environment variable for that
storage location anyway; we should be exposing the
getFilesDir()/getDir() etc. API in the android module.

Then there's External Storage which is definitely left alone through
application upgrades and removals. Its state and location is obtained
using getExternalStorageState() and getExternalFilesDir().

It'd also be good to expose the API for saving files to be shared:
getExternalStoragePublicDirectory()

I believe it would be valuable and correct to expose this API in
python-for-android and use it in Kivy.


Richard
> --
> You received this message because you are subscribed to the Google Groups
> "Kivy users support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to kivy-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Mathieu Virbel

unread,
Feb 11, 2013, 7:59:49 AM2/11/13
to kivy-...@googlegroups.com
Ok, i now understand the deal.

Let's implement an app.get_user_dir() method, as described in a previous
email on the ml.

https://github.com/kivy/kivy/issues/952

Le 06/02/2013 04:11, Richard Jones a �crit :

Richard Jones

unread,
Feb 11, 2013, 5:29:42 PM2/11/13
to kivy-...@googlegroups.com
Great,

I would also like to expose the settings and sqlite API. I'll see about finding some time :-)


    Richard

On Monday, February 11, 2013 11:59:49 PM UTC+11, Mathieu Virbel wrote:
Ok, i now understand the deal.

Let's implement an app.get_user_dir() method, as described in a previous
email on the ml.

https://github.com/kivy/kivy/issues/952

Le 06/02/2013 04:11, Richard Jones a �crit :

Sam Brotherton

unread,
Feb 11, 2013, 5:31:56 PM2/11/13
to kivy-...@googlegroups.com
This is a fantastic idea. I've been using the app directory as well, and weird things seem to happen with it.


On Mon, Feb 11, 2013 at 4:59 AM, Mathieu Virbel <txp...@gmail.com> wrote:
Ok, i now understand the deal.

Let's implement an app.get_user_dir() method, as described in a previous
email on the ml.

https://github.com/kivy/kivy/issues/952

Mathieu Virbel

unread,
Feb 11, 2013, 6:02:46 PM2/11/13
to kivy-...@googlegroups.com
I don't understand "exposing settings and sqlite API", what do you mean ?

Le 11/02/2013 23:29, Richard Jones a �crit :
> Great,
>
> I would also like to expose the settings and sqlite API. I'll see about
> finding some time :-)
>
>
> Richard
>
> On Monday, February 11, 2013 11:59:49 PM UTC+11, Mathieu Virbel wrote:
>
> Ok, i now understand the deal.
>
> Let's implement an app.get_user_dir() method, as described in a
> previous
> email on the ml.
>
> https://github.com/kivy/kivy/issues/952
> <https://github.com/kivy/kivy/issues/952>
>
> Le 06/02/2013 04:11, Richard Jones a �crit :
> >> email to kivy-users+...@googlegroups.com <javascript:>.
> >> For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.

Richard Jones

unread,
Feb 11, 2013, 6:59:05 PM2/11/13
to kivy-...@googlegroups.com
On Tuesday, February 12, 2013 10:02:46 AM UTC+11, Mathieu Virbel wrote:
I don't understand "exposing settings and sqlite API", what do you mean ?

Sorry, I was referring to the Shared Preferences API (getPreferences() and getSharedPreferences()) and the SQLiteDatabase API.


     Richard

Reply all
Reply to author
Forward
0 new messages