2017년 3월 9일 목요일

Apps data bases


. so, i built an app in AI 2 . i downloaded it to my phone and it is also available in the play store

my problem is that sometimes, all the saved data just getting delete from my phone for no apparent reason
Is there a limit for how much data can the app hold?

--
I assume you are using a TinyDB?

MIT says the only space limitations involved are whether the device can store this file.   See this discussion:   How Hard Can You Push TinyDb?   for an explanation.

"sometimes, all the saved data just getting delete from my phone for no apparent reason"  MIT indicates "The source code uses an android.content.SharedPreferences.Editor to store key/value pairs, and uses its commit operation to commit the transaction. It's not clear from the documentation what happens if there's not enough space for the resulting XML file. I would assume the commit returns false in this case, but I'm not sure. However, there's no check for the false case in the App Inventor code, so my best guess is that this would fail silently."

Since this was posted in January, no additional information is available.  
--
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

-- 
after i tried some things, it's seems like all the data deletes after i am trying to save an image  or a color in a separate tinyDB (or the same one) f
another thing i noticed is that in my phone, in the app's page in the settings, the data this app has, is 16kb, no matter what i stored in there
screenshot of the relevant blocks want help, because it's effect all the tinyDBs in the app

--
We can not 'see' your code blocks. That makes it almost impossible for us to provide advice.  Taifun made his suggestion so users here might provide suggestions based on your code and what you are trying to save.

1) It is possible you are writing over your own data
2) It is possible you are using the clear command    call TinyDB.ClearAll     somewhere in your app.   If you do, you clear ALL the data from the DB. You need to use the clear command while developing but you need to remove it when you build the apk.
3) It is possible you use the  call TinyDB.ClearTag tag   command improperly.
4) It is possible you are writing blank data to a Tag that has data, overwriting the contents with 'nothing'.
5) It is possible you are exceeding the data memory of your device, especially if you are loading large images.
6) Images are NOT stored in the TinyDB.  What you are probably doing with respect to. your images is storing them in the directory you told the app to store them.  To know where they are stored, one needs to see your code.
7) The documentation for TinyDB is here:  http://ai2.appinventor.mit.edu/reference/components/storage.html#TinyDB  
8) If the type of data you store is text or csv data, you may be better off using the File control to load a file with the data, use the data and if you change the data, save the revised data to the text file.   Sorry, you cannot save images this way.

9 - You decided that providing us a screen shot of you blocks won't help?   Sorry, only way we can help is to understand your code and to know how many images you are storing and how large (file size) they are.is to see an image of typical code where you save an image   It appears you have lots of images.  Your phone does not have an unlimited memory. You might use your phone's Gallery app to find the images you already have stored on your phone...there may be a lot of them.

--
okay, so here is a screenshot of one of my tiny db's in the app
i did not done any of the things you wrote, and the reason i think a screenshot won't help is because all of the data in all of my DB's was deleted after i saved an image in other db
and i did used a lot with db's before, so i do know the blocks of it, and never had this problem before
if needed, i will post another screenshot (this is a multiscreens app, so all the db's and the blocks are in diffrent places

those are some of the blocks that made the problem

--
First thing I noticed is you're using at least two different TinyDBs in this app, which is redundant...no matter how many you add to the app in the designer, they will all share the same data store.

Second thing I noticed is your second store value method is calling the value and adding 1 to it which can probably work but you really shouldn't do this.  Load the value into a variable, perform your math function, then store the updated variable value in the TinyDB.

--
i split the DBs just that it will be more clear to me
but why isn't adding one that way isn't good like the other way? is it Overloading the DB or something? i'm pretty sure this is not the problem, because i'm doing it for months in almost every project i create and never had this issue

--
You  did not understand.  The images you may save are NOT stored in the TinyDB  The what you might save in the TinyDB is a link to the image.
We still do not know where the images were supposed to be stored on you device.   Your images might be be in a folder called  background.    If you have a file management app on your phone and search for that folder, you may find the missing images even though the links withing the TinyDB have 'disappeared.'    I suspect by using the File Management app that might be on your phone or the Gallery app that should also be there, you MIGHT find the images.    Have you TRIED that?

Be aware:

Accessing images and sounds
Applications built with App Inventor can access sound, image, and video sources from three different kinds of locations:
Application assets
The sources labeled Media shown in the designer — part of the application's assets — are packaged with the application. Anyone who installs your application will have them, as part of the application. You also specify them in the designer, which is convenient. You can also specify these in programs by their file name: just use the file name without any special prefix. For example, if you have an image asset named kitty.png , you can use it as an image: just set the Picture property of an image component to the text kitty.png . You can similarly use files names for sound (Sound or Player) or video (VideoPlayer).
Assets are the most convenient to use, but the space for them is limited to a few megabytes, because they must be packaged with the application. They are good for small images and short audio selections. Bit you would probably not use them for complete songs or videos.
The phone SD card
You can access files on your phone's SD (secure digital) card using file names that begin with /sdcard . You could play a song on your SDCard by setting the source of a Player component to
/sdcard/Music/Blondie/The Best of Blondie/Heart of Glass.mp3
and starting the Player (assuming of course, that the song file is on the SDCard). Make sure to specify the complete file name, including the "mp3".
The Android system also includes an alternative way to designe SDCard files as URLs. Here you prefix the file name with file:///sdcard and use "URL encoding" for special characters. For example, a space is "%20". So you could designate the same file by setting the player source to
file:///sdcard/Music/Blondie/The%20Best%20of%20Blondie/Heart%20of%20Glass.mp3
Note that you'll want to use a Player component for this, not Sound . A complete song like this is too large for Sound to handle.
Images and videos can be designated similarly.
App Inventor doesn't (yet) include any way to store files on the SD card. It also doesn't (yet) include a way to list the files on the SDCard. You'll have to use other applications or the Android phone file manager for that.
Using the SD Card provides a lot more space for media than trying to package things as assets. The drawback is that users won't automatically get them by installing your application.

It is possible that you reached a limit in storing the images on your PC.  This was discussed earlier and if you did not make a coding mistake, is the most likely reason for the disappearance.

Here is the correct way to 'store' images; http://stackoverflow.com/questions/18131686/tinydb-storing-images-or-paths-to-them-and-viewing-them   ... this is in AI2 Classic, the principles apply to AI2 and someone might provide a link to an AI2 'translation"

--
yes, i did
but my problem is not that the images (that i take from the gallary with image picker) and store in tinyDB, are disappearing
,my problem is that when i save those images, everything else is disappearing
like all the text i saves in the tinyDB's
the pictures are still shown in the app, and in the gallary folder they came from, and also in a gallary folder of app inventor

--
Rosenbergguy,
I think you did not. Do you want help? Yes or no? If yes, you should read what Steve wrote.
Your problem is that you are trying to save an image into a TinyDB, I saw that from your blocks. Steve said that you cannot store images in a TinyDB. Maybe that is the reason everything else is disappearing.

-- 
my problem is that when i save those images, everything else is disappearing
like all the text i saves in the tinyDB's

probably you like to provide a screenshot of these blocks to save that text in TinyDB and to read that text from TinyDB?

--
sorry. i missunderstood what he said
but thank you all, i saved the image path like steve said, then stored it, and nothing deleted , all worked just fine 

--

댓글 없음:

댓글 쓰기