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 

--

Random Audio


Just curious how do I make a random list? I'm not finding the Blocks for it. I have links to my audio files and I have everything set up to make one play but I want it to choose from a random list of URLs that I plug in.  I can't seem to figure it out with AI2.

--
There's a block to pick a random item from a list in the lists drawer.

--
Solved! Thanks Scott - The little Tutorial Vid did the trick...

--



fill text box in for calculation


i would like to make a equation calculator but i would also like to have 2 text boxes where i can write for example 2 in the first box and 4 in the second box. And then that i puss on a button calculate and that it gives me 6

does someone could help me making this program.

--
What have you tried?

Searching the forum for similar questions, I can find these links:  https://groups.google.com/forum/#!searchin/mitappinventortest/calculator   by typing  calculator in the Search for topics box at the top of the page and next to the colorful Google.   Your answer is there, but you will have to search for it.    If yuu type  equation into the box, you get:  https://groups.google.com/forum/#!searchin/mitappinventortest/equation

Another way to get an answer is to read the free online book about AI2 programming here: http://www.appinventor.org/book2   , the links to the chapters are at the bottom of the Web page.

Have you done any of the MIT tutorials?...a great place to learn how to program.http://appinventor.mit.edu/explore/ai2/tutorials.html

You might try something like this:

--


Ai2 - Number crunching !


I am a 'silver user' & new to Ai2, have lots of experience with making routines in Excel (so can follow/create logical paths etc) of which many are used on my phone & tablet.
Discovering Ai2 seemed a good way to make routines more 'slick' and easier to use !!
I am not interested in games, bouncing balls etc.but mainly interested in simple number crunching for both hobbies and work (CEng in lighting).

My task is as follows (to replicate one excel routine used):
I have 3 user input values (currently from drop-down box but not important to be so)
I have one calculated value from  2 of the 3 user inputs that is used later on.
I also have 3 in-built fixed conversion values
The output, once the 3 user inputs are entered give the desired result.
Functions applied are simple X & / so no radians etc.

I discovered Ai via Mike McGrath's book 'Building Android Apps' however this is for Ai1 (Classic) and I would prefer to use Ai2 where information is as yet limited. I have tried to follow books Ai1 block building logic but penny hasn't dropped in Ai2.

Can anyone point me in a good direction to build app as described and focusing on number input / output display ?
I'm sure once I have managed to build above simple routine in Ai2 I can apply to other routines currently used in Excel.

--
This is the perfect match for App Inventor as one of it's strong points is number crunching.
This includes support for imaginary numbers: a+bi (needed when you want the square root of a negative number), scientific notation: 3.14e-7, etc.
There is a function to convert to radians but degrees is the default.

The data entry part is a snap as well.
I have been unable to find a good example in AI2 for what you want to do but it should be fairly simple.

I have 3 user input values (currently from drop-down box but not important to be so)
In App Inventor you can create a ListPicker instance in the Designer Viewer and on the right put the three values in the Elements box separated by commas.
By default it will be named ListPicker1.

I have one calculated value from  2 of the 3 user inputs that is used later on.
I also have 3 in-built fixed conversion values
The output, once the 3 user inputs are entered give the desired result.
Functions applied are simple X & / so no radians etc.

All of the above can be done with local variables in one Button Click block.

If you prefer, we can do a Google Hangout and I will show you how to do it using the share screens feature.

--
Many thanks for your comments very helpful.
I will continue to experiment along the lines you have mentioned.
I'm sure once I get to grips with the logic of the blocks it will be simple.

I'm not a Hangout user so maybe not a good option !

If you don't consider me very cheeky perhaps you could post a screenshot of a typical block arrangement that I could replicate and develop ?  Iv'e designed the screens (I'm using imperial and metric options as well as a text instruction screen) and have managed to get the navigation sorted with 'on button press go to screen#' so chuffed with myself for that albeit simple element.
Its just which blocks to use/start with and their relationship for the maths, hence the cheeky question !

--
Here is a link to a video where a 4 function calculator is built from the ground up.

http://www.youtube.com/watch?v=1BuKR7S2Gl0




It should be usable in either version of App Inventor,
and should show you how to handle input/output.

If you are having problems with conversions or formulas,
could you post them here?

If you want to post blocks, take a screen shot of them in the Block Editor
using your PrtSc key, save them using your Paint program,
and post them as files here.

That would be easier on the people reading the posts than
lab samples.

--
It would be easiest if you would export and attach here the aia file and provide a description of the input values and formula used.
I could then make the changes and post the blocks from your app here and return the 'fixed' project as an attachment.
It is mostly a matter of putting the math blocks in the correct arrangement.
Once I have posted a picture of the blocks I can explain how they work.

--
Update:
With Scott's very kind assistance have now built 1st app !!
Whilst in Ai2 and connected to my mobile (Samsug Galaxy Mini 3 running Android 4.1.2) and chose drop-down pick list the list appeared for a millisecond then closed the app.
Before picklists added worked OK on phone.
However it runs on Nexus 7 absolutly great with no problems whatsoever.

Has anyone an idea of why this should be ?
Clearly something on the mobile but maybe something in the app could mitigate issue, as it worked before picklist added.

--
I have posted an update on the forum site as suggested.
Many thanks for assistance, I have replicated to the metric screen and all works fine.
Have also added screen image, rounded buttons etc.
The only thing I couldn't replicate was the down arrow icon for the list picker button, nothing on my keyboard would replicate this.
On the mobile, application loaded as apk and runs but the selection is not passed to the input box from the selected picklist item, but can type in numbers so workable.
Very strange as works great on Nexus 7.
Still as you say perhaps a quirk on the phone.


--
The only thing I couldn't replicate was the down arrow icon for the list picker button, nothing on my keyboard would replicate this.
Click the start menu button in Windows and type charmap in the textbox.
Press enter and a dialog with characters is displayed.
I selected the OpenSymbol font then used the select and copy buttons there to copy the smaller down triangle to the Windows clipboard, then pasted it in the textbox for the ListPicker.
--


calculator AI2 source code


I thank you all for this great project.
(MIT App Inventor 2)
I'm a newby and I'd like to find some
source code to practice with a calculator
I changed the extention .zip into .aia and imported in project,
but I can't the block (code), I see only the design.
Where do I can find an example of code for AI2?
Another thing I'd like to do, is to add to the calcualator
to test storage:
log all the input and output ...
Thank you in advance for any help,

--
sorry for posting,
I found an example here: AI2: MyCalculator: A simple four-function calculator

-- 

GPA Calculator, how do you translate a letter grade in Spinner into point value?


Hello, I have a question. How do you define the value of a selection? For example, I am creating a GPA calculator app, and I need to translate the letter grade in the selection into a grade point value such as A=4.0,B=3.0 etc. How do you do that?

-- 
Look at Scott's GPA for part of the answer:  GPA calculator  

--
Set up a list of lists.
(
(A,4.0)
(B,3.0)
...)

Then use the look up in list block to turn "A" into 4.0

--

GPA calculator


I'm having some difficulty designing a GPA calculator in Appinventor 2. I believe I have most of the calculations correct but I can't figure out a way to convert letter grades (A, A-, B etc.) to GPA numbers (4.0,3.7.3.0 etc). I think its something with my procedure. Can any of you guys check out my .aia file and offer an opinion?


--
I you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...


To download the aia file, upload it to  App Inventor, open it, do some bug hunting for you, etc...
this takes time, and most people will not do that...

--
After looking at your blocks and the way that it was recommended that GPA be calculated here: http://www.wikihow.com/Sample/GPA-by-Credits
I felt it best to show how you can use the TextBox component blocks to iterate through the two lists needed to build the totals for the GPA calculation.
It was not as simple as I initially thought it would be when thinking about averaging a set of grades.
total credits is easy to sum up, but total grade points is the total of the credits X scale values for each grade - and the scale value must be looked up with the letter grade.
The solution shown uses advanced TextBox.Text blocks and it is assumed that all five letter grade and credit boxes are filled with values.
Allowing for less than five letter grades and credit values would require additional blocks to determine when to stop adding.  
This could be done by the user entering the number of grades or having a loop that adds 1 to a counter until it reaches 5 or the first empty TextBox.
I challenge you to add at least one more grade to your list to show that you understand how this works and post your solution here.
Can you also make it more flexible by allowing fewer than the maximum courses?
Keep in mind that attempting to use a blank text value in a math calculation will throw an error :(


--
Closing this issue as there has been no response from the original poster.

--

Trigonometry Calculator with promotionvideo


I've made a math app where you can calculate lengths and angles in triangles.


I've use ADB shell screenrecord to record the app in function and made a YouTube video.


The video is also used as promotionvideo on Play Store.

--
Why does this app need to know my current position?

--
Because it has advertising in it.

--
Ok, i understand.
My follow up question then is:
Is it worth to have obviously app-unneccesary permissions for the benefit of adds? Does this model realy work?


--
I did not Ask for this permission by myself.
I'm using Ailivecomplete and the admob-component. This component for some reason put the permission request. Maybe to provide targeted ads that are for the user location. But as far as I have read, you're right — There is no actually need to ask this —the admob will work without.
The Way  to remove it — is to use Apptomarket and remove the permissionrequest in the manifest...as far as I know 

--