[Q] Get a list of database names in code from android app? - General Questions and Answers

Hello,
I would like to get a list of database names in code. I'm not looking for databases outside my application/package, just those in my /data/data/<my_package>/database folder.
I can easily locate them on the file system and open them using adb and sqlite3,
but I need to dynamically get a list of databases so that I can open and manage them in code.
I currently use a separate database to keep track of database names as they get created/deleted through my application, but I imagine there is a way to get a list of databases directly via SQL query or some sqlite library call.
Can anyone help me with this?
Thanks,
-dj

This should be in the "Android Development" forum.
BTW, I tried to post this question in a more topical "Android Development" forum, but I'm an XDA newb and don't have permissions to post in there.

Maybe these links can help you? I don't do much droid programming anymore and I never worked with databases in droid. Also welcome to XDA
http://www.devx.com/wireless/Article/40842
http://developer.android.com/reference/android/database/sqlite/package-summary.html

solution
The solution turned out to be very simple.
The main application context has a databaseList() function that, conveniently, returns a list of database names associated with the application.
String[] dbList = getApplicationContext().databaseList();
Thanks for the links dbzfanatic. devx looks like a good resource... it's going on my bookmark bar for sure.

Glad I could help and thanks for posting the solution for others who might have the same question. Since it's a string array I'm guessing the function just returns the DB names and not handles to them?

database names
dbzfanatic said:
Glad I could help and thanks for posting the solution for others who might have the same question. Since it's a string array I'm guessing the function just returns the DB names and not handles to them?
Click to expand...
Click to collapse
Correct, just a list of the database names.
I need a few more posts before I'm permitted to post a link, but this is the approximate reference link:
developer.android.com/reference/android/content/Context.html#databaseList()

Related

need help with very small program for myself.. plz help

im trying to get a very very small program runnint, however im very lost when it comes to programming windows mobile device, i have a database online, and i want a small dialog box to show up on my wm device and alow me to type something in , then it search the online database.. and return the information, or even just take me to where the online listing is, that's all no bells or whistles.. could someone help me with this please?
i have even added a search feature to my database, soo i just basically want this little program to relay text to that search feature, then take me to it.. so i don't have to go to all these links and whatnot
Well,
it is quite hard to advice you anything without actually knowing about the file structure / database format. Maybe the easiest way would be to simply set up a search option online as a WAP2.0 page - if you don't want others to access this section, simply password protect it.
If you really have a need to generate the 'search string' offline (which I just can't understand since you want to be taken to your DB online) then simply use something which generates the search string for you.
For example you could have a "results.php" online which simply needs the search terms 'attached' in order to list you all relevant records. Now, the question remains how the database is structured. If you have 2 fields in your database, containing firstname and lastname, then it would be simple. You would need only something that adds your search terms to the string and then navigates to your server. For example you search for SMITH as lastname, it would have to transfer the string as followed:
www.mysite.com/results.php?lastname=smith
For sure your results.php needs to be programmed first!
However,
this has nothing to do with your device, you better join a programmer forum - in this case I would suggest you look for web development forums since this can be done entirely on the server side!

[Q] Info on Database programming on Android

Ok, I'm trying to build my first app that interacts with a Database. Essentially I'm going to have a list of parts with a name, location, and serial number stored in a database. I would like to add, delete, and update rows. I tried following the Notepad example but I'm having trouble following. Not really understanding why and how they are using somethings. I have had database programing but its been a while and need a refresher. Anyone know where I could go to find more detail explanations of achieving my goal for this database?
Thank you in advance.
T.
TayOnG1 said:
Ok, I'm trying to build my first app that interacts with a Database. Essentially I'm going to have a list of parts with a name, location, and serial number stored in a database. I would like to add, delete, and update rows. I tried following the Notepad example but I'm having trouble following. Not really understanding why and how they are using somethings. I have had database programing but its been a while and need a refresher. Anyone know where I could go to find more detail explanations of achieving my goal for this database?
Thank you in advance.
T.
Click to expand...
Click to collapse
All major mobile O/S's include SQLite. You cann drive SQLite through C, Java or any scripting languages. You need to learn less than 10 SQL commands to survive. I bought a couple of books (recommend O'Reilly's Using SQLite), and now I get 95% of the commands correct first time.
Thank you I will check out that book.
Sent from my HTC Vision using XDA App

how to play .pls on Windows phone 7

Can anyone tell me how to play .pls on Windows phone 7 media element
Maybe you get the answer when you clone this thread 10 times.
Until now you did it only three times.
http://forum.xda-developers.com/showthread.php?t=1852573
http://forum.xda-developers.com/showthread.php?t=1852581
http://forum.xda-developers.com/showthread.php?t=1854194
Try several times more. But first - go read forum rules - especially the chapter about creating new threads.
I've closed all your similar repetitive threads. Please read the XDA ruls before posting: http://forum.xda-developers.com/showthread.php?t=726334
This thread remains open for getting your answer.
Moved to related forum.
WP7 doesn't natively understand the format, of course, so you'd need an app that could process it. The app would have to parse the playlist files, acquire the actual media files, and then play the media files (such as through a MediaElement) one at a time in the order specified by the playlist(s). None of this should be too hard.
Now, if you want to be able to open a .PLS file directly on WP7 - that is, from an email attachment or a download link on a webpage or something like that - you'll need to be able to set file associations. This is possible, but requires at least interop-unlock on your phone or root-unlock on your app. You need to add an entry under HKEY_CLASSES_ROOT for .PLS, with the default value specifying something like "plsplaylist", and then create HKCR\plsplaylist, give it a registry value called EditFlags of 0x00010000, and create additional registry keys HKCR\plsplaylist\shell\open\command with a default value of your app's launch URI (app://{APP_PRODUCT_ID_HERE}/_default?pls=%s). To understand that, your app would need to have a check in its OnNavigatedTo event that examines the parameters of the navigation for the key "pls" and loads the file represented by its value.

[Q] Business App Template - Is it possible?

Hey guys,
I'm really new to this app development and would like to ask one of you experienced developers a question.
Basically I have recently been creating mobile websites from a set of css files which are just a basic template. The template files have individual files for some of the most common pages that a small business would need, google map, contact us with form, menu, opening hours and so on.
What happens is you simply upload the company logo and such into the images folder, update the css style sheet for colours, then simply edit one of the relevant pages e.g place the food items in the menu page.
When the whole set of files gets uploaded it creates a personalised functional business mobile website.
What I would like to know is, would it be possible to set something like this up for an android app? Whereby the user could simply change the details as above and then compile the apk file which will create the app?
Your input is much appreciated, also have any of you got any idea where I could get someone to code something like this?
Regards,
Stephen

[APP][2.2+] Backitude - Server-side development

I am creating this thread to start an area for Backitude server side developers and for casual users looking to implement their own flavor of location history or Google Latitude, to come and chat, ask questions, and get information.
Backitude is an android application that allows users to track their device locations in a highly configurable and continuous manner. Location data can be stored locally as (KML, CSV) or posted to a custom server. Anyone can create their own server implementation for storing or sharing location data.
Currently, three users are sharing their implementations:
http://backitude.ascanwex.de/ ([email protected])
-and-
https://bitbucket.org/nparley/mylatitude/wiki/Home ([email protected])
-and-
http://www.backituders.com ([email protected])
Let me know if more exist you would like me to add to the list!
Quick hack for using Traccar as backend
Hi,
If you want to use Traccar as the backend, then you can quickly implement a server side fix in PHP that converts the HTTP POST from Backitude to the required HTTP GET request OsmAnd style that Traccar expects.
Requirements:
- HTTP server with PHP
Place a backitude.php file with this content on your Traccar server:
PHP:
<?
$data=$_POST;
array_walk($data , create_function('&$v,$k', '$v = $k."=".$v ;'));
$url='http://127.0.0.1:5055?'.implode("&",$data);
$response = file_get_contents($url);.
echo "200 OK\n";
?>
Replace 127.0.0.1 with your Traccar server, if it's located on another host than the one you put the PHP code in.
Configure Backitude like this:
Server URL: http://<yourserveraddress>/backitude.php
Successfull response code: 200
Authentication: none
Custom field1: <enter your imei or the ID youre using in Traccar>
Latitude: lat
Longitude: lon
Accuracy: hdop
Speed: speed
Altitude: altitude
Direction Bearing: bearing
Location Timestamp (UTC): timestamp
TimeZone Offset: do not post/empty
Custom Field 1: id
Works for me! Thanks a lot for Backitude - the Traccar client is not nearly as reliable or battery friendly as Backitude.
wire103 said:
Hi,
If you want to use Traccar as the backend, then you can quickly implement a server side fix in PHP that converts the HTTP POST from Backitude to the required HTTP GET request OsmAnd style that Traccar expects.
Requirements:
- HTTP server with PHP
Place a backitude.php file with this content on your Traccar server:
PHP:
<?
$data=$_POST;
array_walk($data , create_function('&$v,$k', '$v = $k."=".$v ;'));
$url='http://127.0.0.1:5055?'.implode("&",$data);
$response = file_get_contents($url);.
echo "200 OK\n";
?>
Replace 127.0.0.1 with your Traccar server, if it's located on another host than the one you put the PHP code in.
Click to expand...
Click to collapse
Would this whole implementation be a lot simpler, if Backitude sent over a GET instead of a POST ?
Yes, a toggle switch between GET and POST would make your program directly compatible, if the user can set port number on the URL as well.
Sendt fra min GT-I9505 med Tapatalk
To repost from the other thread:
I have finally got around to opening up my Google App Engine app code. It runs on the free quota on Google App Engine and so it does not require you to pay for a server. Also as it's your app you have control of your location data, and can delete it at any time by going into the Google App Engine settings for your app. You send your location to your app and it is recorded in a database. The app allows you to share your location with other people by creating a white list of allowed Google accounts. I have also made a history page which you can use to see your updates from each day. I can't add links but you should be able to find the code at bitbucket.org / nparley
No doubt there will be bugs which I have not found. If you find one please add an issue to on the bitbucket page. I will continue to add new features as I can but am open to requests, just add a feature requestion issue on bitbucket.
Cheers,
Neil
[B[/B][/B]
nparley said:
To repost from the other thread:
I have finally got around to opening up my Google App Engine app code. It runs on the free quota on Google App Engine and so it does not require you to pay for a server. Also as it's your app you have control of your location data, and can delete it at any time by going into the Google App Engine settings for your app. You send your location to your app and it is recorded in a database. The app allows you to share your location with other people by creating a white list of allowed Google accounts. I have also made a history page which you can use to see your updates from each day. I can't add links but you should be able to find the code at bitbucket.org / nparley
No doubt there will be bugs which I have not found. If you find one please add an issue to on the bitbucket page. I will continue to add new features as I can but am open to requests, just add a feature requestion issue on bitbucket.
Cheers,
Neil
Click to expand...
Click to collapse
ON WEB PAGE IT SHOWS ONLY "Hello world!"
holysmoke001 said:
[B[/B][/B]
ON WEB PAGE IT SHOWS ONLY "Hello world!"
Click to expand...
Click to collapse
Hi holysmoke001,
I am not quite sure what you are referring to,
Neil
nparley said:
Hi holysmoke001,
I am not quite sure what you are referring to,
Neil
Click to expand...
Click to collapse
Hi Neil
I follow all your instructions for Setting up the app but when i go to yourapp(my app).appspot.com/
IT SHOWS ONLY "Hello world!" written on corner of the web page.
can you please upload detailed instructions step by step how to set up the app
holysmoke001 said:
Hi Neil
I follow all your instructions for Setting up the app but when i go to yourapp(my app).appspot.com/
IT SHOWS ONLY "Hello world!" written on corner of the web page.
can you please upload detailed instructions step by step how to set up the app
Click to expand...
Click to collapse
I assume you have done all the steps here? https://bitbucket.org/nparley/mylatitude/wiki/Setup App Does your site say running if you go to here https://appengine.google.com/
---------- Post added at 09:34 PM ---------- Previous post was at 09:26 PM ----------
holysmoke001 said:
Hi Neil
I follow all your instructions for Setting up the app but when i go to yourapp(my app).appspot.com/
IT SHOWS ONLY "Hello world!" written on corner of the web page.
can you please upload detailed instructions step by step how to set up the app
Click to expand...
Click to collapse
OK the problem could be this https://code.google.com/p/google-app-engine-samples/issues/detail?id=40 i.e. the path is wrong and the app engine application launcher has created another default app.yaml and app.py file.
nparley said:
I assume you have done all the steps here? //bitbucket.org/nparley/mylatitude/wiki/Setup%20App Does your site say running if you go to here://appengine.google.com
---------- Post added at 09:34 PM ---------- Previous post was at 09:26 PM ----------
OK the problem could be this //code.google.com/p/google-app-engine-samples/issues/detail?id=40 i.e. the path is wrong and the app engine application launcher has created another default app.yaml and app.py file.
Click to expand...
Click to collapse
yes problem is same.Launcher is creating a new folder inside my project folder with a default main.py and app.yaml file.
my project folder is JMlatitude and i copied my client secret file in JMlatitude folder and edited the app.yaml file as JMlatitude.yaml but launcher is creating new folder (JMlatitude) inside project folder.pls help what to do
Thanks Brian for the dedicated post.
This is how to get started with my service (www.backituders.com).
0) The service is free
1) Drop me an email to [email protected] backituders <Dot> com. You'll get a username pwd password back.
2) Start using backituders!
You can find more infos, expandoing docs and guides at www.backituders.com.
Backituders is meant as an API you can use to implement your own applications on. I provide the server and APIs to set and get positions, set alamers and alerts and so on. There is also a ready-to-use "draw my map" and "follow my device live" feature.
Will use this post as updates to the service are done.
- 20131031: display timestamps in RFC format, display speed
- 20131104: changed the icons on the map to reflect direction (8 main dir) when available.
- 20131104: sono disponibili istruzioni base in italiano.
Thanks any for testing.
holysmoke001 said:
yes problem is same.Launcher is creating a new folder inside my project folder with a default main.py and app.yaml file.
my project folder is JMlatitude and i copied my client secret file in JMlatitude folder and edited the app.yaml file as JMlatitude.yaml but launcher is creating new folder (JMlatitude) inside project folder.pls help what to do
Click to expand...
Click to collapse
Hi,
Sorry I might not have been clear in my instructions. You have to keep the file named app.yaml as this is the file Google App Engine looks for and will create a new one if not found. It is inside this file where you have to make the edit, the top line contains `application: YOURAPPNAME` here you have to change YOURAPPNAME to JMlatitude.
Neil
nparley said:
Hi,
Sorry I might not have been clear in my instructions. You have to keep the file named app.yaml as this is the file Google App Engine looks for and will create a new one if not found. It is inside this file where you have to make the edit, the top line contains `application: YOURAPPNAME` here you have to change YOURAPPNAME to JMlatitude.
Neil
Click to expand...
Click to collapse
Thanks Neil its working now
Hi Neil pls help me in setting up backitude custom server settings
1.there are two custom field 1 one in request parameter values and another is in request parameter keys .which key i have to fill in both custom fields
API key or application key setup at yourapp.appspot.com. when i fill custom field 1 in request parameter values it shows no custom field parameter key configured, value will not post (configure below) when i run test it shows error gaugler.backitude.service.backitudeException:Custom Server POST failure: HTTP/1.1400 Bad Request
2. what to fill in Device ID
holysmoke001 said:
Hi Neil pls help me in setting up backitude custom server settings
1.there are two custom field 1 one in request parameter values and another is in request parameter keys .which key i have to fill in both custom fields
API key or application key setup at yourapp.appspot.com. when i fill custom field 1 in request parameter values it shows no custom field parameter key configured, value will not post (configure below) when i run test it shows error gaugler.backitude.service.backitudeException:Custom Server POST failure: HTTP/1.1400 Bad Request
2. what to fill in Device ID
Click to expand...
Click to collapse
Get the key from going here: yourapp.appspot.com/viewkey. You want to end up with something like this:
https://bytebucket.org/nparley/mylatitude/wiki/settings.png I.e. at the top in the custom field type your long key. Under requestion parameter keys change custom field 1 (it'll have no value to start with) to the word "key". I don't seem to have a device ID on my backitude version are you sure you have the latest version from the play store? (or try leaving it bank) Also make sure you change the response codes to 200,202
Neil
Trying to set up the app in google apps
nparley said:
To repost from the other thread:
I have finally got around to opening up my Google App Engine app code. It runs on the free quota on Google App Engine and so it does not require you to pay for a server. Also as it's your app you have control of your location data, and can delete it at any time by going into the Google App Engine settings for your app. You send your location to your app and it is recorded in a database. The app allows you to share your location with other people by creating a white list of allowed Google accounts. I have also made a history page which you can use to see your updates from each day. I can't add links but you should be able to find the code at bitbucket.org / nparley
No doubt there will be bugs which I have not found. If you find one please add an issue to on the bitbucket page. I will continue to add new features as I can but am open to requests, just add a feature requestion issue on bitbucket.
Cheers,
Neil
Click to expand...
Click to collapse
I have also tried to set up the app with google engine. I got stuck where I need to download a copy of my app code. I have no idea how to do this. In the description you wrote to download the latest .zip or clone the git repo into a directory. How will I be able to do that?
Thanks for helping me.
regards
Manfred
nparley said:
Get the key from going here: yourapp.appspot.com/viewkey. You want to end up with something like this:
https://bytebucket.org/nparley/mylatitude/wiki/settings.png I.e. at the top in the custom field type your long key. Under requestion parameter keys change custom field 1 (it'll have no value to start with) to the word "key". I don't seem to have a device ID on my backitude version are you sure you have the latest version from the play store? (or try leaving it bank) Also make sure you change the response codes to 200,202
Neil
Click to expand...
Click to collapse
Hi Neil!
Great app, finally got it to work. Will report more feedback later!
Good work!!
Error message with key
nparley said:
Get the key from going here: yourapp.appspot.com/viewkey. You want to end up with something like this:
https://bytebucket.org/nparley/mylatitude/wiki/settings.png I.e. at the top in the custom field type your long key. Under requestion parameter keys change custom field 1 (it'll have no value to start with) to the word "key". I don't seem to have a device ID on my backitude version are you sure you have the latest version from the play store? (or try leaving it bank) Also make sure you change the response codes to 200,202
Neil
Click to expand...
Click to collapse
Hi Neil!
Now the app worked for a couple of hours and now I get this message:
Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v3 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: https://developers.google.com/maps/documentation/javascript/tutorial#api_key
Do you have any idea what I could do?
Thanks!
dukerider33 said:
Hi Neil!
Now the app worked for a couple of hours and now I get this message:
Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v3 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: https://developers.google.com/maps/documentation/javascript/tutorial#api_key
Do you have any idea what I could do?
Thanks!
Click to expand...
Click to collapse
This probably means you have your Google maps api key wrong or you did not fill in your Google maps api in when you setup the app. The instructions show you where to get the browser api key from, it's this page https://code.google.com/apis to get your Google maps browser api key. You can go here https://appengine.google.com log in to your app, click on data store viewer, in the by kind drop down pick maps the keyid should equal the key you get from the Google api console. You can edit it if it's not correct. If you have no maps kind in the data store you need to delete all the users and run the setup again.
Hopes this gives you some help trubble shooting,
Neil
nparley said:
This probably means you have your Google maps api key wrong or you did not fill in your Google maps api in when you setup the app. The instructions show you where to get the browser api key from, it's this page https://code.google.com/apis to get your Google maps browser api key. You can go here https://appengine.google.com log in to your app, click on data store viewer, in the by kind drop down pick maps the keyid should equal the key you get from the Google api console. You can edit it if it's not correct. If you have no maps kind in the data store you need to delete all the users and run the setup again.
Hopes this gives you some help trubble shooting,
Neil
Click to expand...
Click to collapse
Hi Neil,
had to setup the site completely new from the scratch. Now it works nicely.
Thank you!

Categories

Resources