Android apk and local database in a mobile - Forum

Forum Navigation
You need to log in to create posts and topics.

Android apk and local database in a mobile

Hello

I like to start a project and I need some advices.

The project is a normal android application that I would like to use a local database with all the data. Is that possible because I need my application to work even is not online.

The other question .. is it possible to update the local database when the application start? To check if it is connect to internet and if it is having a new update to download the new version of the database.

Thank you for your time.

The project is a normal android application that I would like to use a local database with all the data. Is that possible because I need my application to work even is not online.

@sakismor for easy implementation, if you don't need a huge database, you can use neoLocalStorage plugin and store the data in JSON format using neoSQL plugin to search, update, etc. all the data. If you want a real database (SQLite) you will need to use a Cordova plugin (I have no experience using it but it shuld be possible).

is it possible to update the local database when the application start?

If you use neoLocalStorage it's quite easy. Just download the online content to a variable using FileToVar and store it using neoSetItem.

To check if it is connect to internet

Use neoDeviceIsOnline to check for an Internet connection

Regards.

Vadim and javadrajabihakami have reacted to this post.
Vadimjavadrajabihakami

Excuse me @luishp, if you have time, can you please post an example of how to use neoSQL with a JSON file ? Things are not clear to me...

Hi @cdy44-2, have you exlored the neoSQL sample app included with VisualNEO Web?
It uses an Excel file as a data source but you can use JSON data exactly the same but instead of using neoSqlExcel use neoSqlJson.
This way you can query JSON data as if it was a real database using standard SQL.

Try this:

CreateEmptyObject [myjson]
neoSqlJson [myjson] "CREATE TABLE test (language INT, hello STRING)" [myjson] ""
neoSqlJson [myjson] "INSERT INTO test VALUES (1,'Hello!')" [myjson] ""
neoSqlJson [myjson] "INSERT INTO test VALUES (2,'Aloha!')" [myjson] ""
neoSqlJson [myjson] "INSERT INTO test VALUES (3,'Bonjour!')" [myjson] ""
neoSqlJson [myjson] "SELECT * FROM test WHERE language > 1" [mydata] ""
Wait 100
  jsAlert [mydata(0).hello]
  jsAlert [mydata(1).hello]
EndWait

Regards.

CDY@44 has reacted to this post.
CDY@44

"have you exlored the neoSQL sample app included with VisualNEO Web? "---  Yes !  There are so much things to learn with samples ! It is my first reaction before asking...but sometimes my (poor) mind is stuck in front of a question...

Thank you so much for the support you give to us !

Have a good day @luishp !

javadrajabihakami has reacted to this post.
javadrajabihakami

Thank you for your solutions!!

  • I have to tell you that I try the real database (SQLite) as a Cordova plugin put is not working well. And the man that makes this is not support any more. Do you have any other solution for a real database that can work without server?
  • About the JSON solution I will like to know if I can have multi tables to one JSON file. And what is the easiest way to put all the data that I need? Maybe is it possible to collect all the data in a excel file with multi sheets and then to convert it to JSON file?
  • At last prefer a new easy way solution that will be a full ready to use plugin like the one that I use for many years with Neobook. Is that possible?

I am really thank you for your support. Best regards

Do you have any other solution for a real database that can work without server?

@sakismor online databases are your best bet. You can locally store information whenever there is not an Internet connection and store it online later when Internet is available again. Due to security restrictions for web applications, the only way to use a real local database is using a Cordova plugin.

About the JSON solution I will like to know if I can have multi tables to one JSON file.

Note that this solution is not a real database, but allows you to store and manage data locally in a similar way. Just remember all the data is loaded into memory so is not a good idea for big databases. But yes, you can have as many "tables" as you need in a single JSON object.

And what is the easiest way to put all the data that I need? Maybe is it possible to collect all the data in a excel file with multi sheets and then to convert it to JSON file?

It depends on how are you getting the data. Note that neoPhp plugin, for example, already loads all the data from SQLite or MySQL into a JSON object you can store locally or export as a file. neoSQL can load data from an Excel or .csv file into a JSON object too (even from Google Sheets)

At last prefer a new easy way solution that will be a full ready to use plugin like the one that I use for many years with Neobook. Is that possible?

Note that local databases are not possible on pure web applications but probably a plugin similar to NeoDbPro for online databases should be possible with a huge effort.

I very much recommend online databases or even neoCms for most situations where a database is necessary.

Best regards.

una pregunta al ejecutar el neosql me pueden dar un ejemplo de lo que debo de escribir en el cuadro de texto porque cuando doy clic en el boton sql  me marca error en terminal y no puedo hacer que aparezca ningún dato

@carlos-saldana no entiendo tu pregunta. ¿Te refieres a alguno de los ejemplos incluidos? Si es así, en el cuadro de texto debes escribir una sentencia SQL válida.

Así es me puedes proporcionar un ejemplo de una sentencia sql valida ya que no la puedo hacer que me muestre nada

en el cuadro aparece  esto al ejecutarlo

SELECT * FROM ? WHERE City LIKE 'Ba%' ORDER BY FirstName me puedes mostrar un ejemplo de lo que debo poner o como lo debo poner por que al dar clic en boton sql no me parece nada en la pantalla ni

 

Uploaded files:
  • You need to login to have access to uploads.

@carlos-saldana ¿lo estás ejecutando en un servidor web? Puedes utilizar neoPhp o cualquier otro. Si no lo haces, como la aplicación necesita acceder a un archivo local, habrá un bloqueo de seguridad del tipo CORS y no podrás ejecutarlo. Fíjate también que pulsando F12 puedes ver la Consola del navegador donde aparecen descritos los errores. De este modo tendrás muchas más pistas de lo que puede estar sucediendo cuando algo no funciona correctamente.

Esta sentencia SQL debe funcionar correctamente:

SELECT * FROM ? WHERE City LIKE 'Ba%' ORDER BY FirstName

El ejemplo online, donde puedes comprobar como funciona lo tienes en este enlace:

https://visualneo.com/tutorials/neosql/

Saludos.