I want to place one txt file (which have insert statements) of size 273 MB, i need to know how to save that file in Phone's memory and how to access that file from my application
If i able to access that file from my application i want to insert that data in my table,already i tried to use to save the file in my application's assets folder to acess the database using database helper but i heard that assets folder can store only files of size 1 MB but my database file size is 273 MB.
For 273mb size file, I think better solution is just put the file in remote server, and using web request get data, also get the data only what you needed not all,
And put table structured database file (Without data) in asset folder and copy that file in application's internal storage then you have to download either file or data from server using web request and fill the database with it..
Update:
When you get data from server at server side make a Select query using OFFSET and LIMIT clause so its returned only bounded limited rows and make request as intervaly so there is no work load on your server and in your application..
This is my personal opinion I may be wrong on this..
If any one has a better solution then please share it..
Thanks..
Related
I am making a flutter app where i have to download files from the a distant server.
but I want to make those files only accessible from my app, and not from other file managers or other apps like Netflix does with their app.
how can I achieve that in flutter?
thank you in advance.
you can use flutter_cache_manager
A CacheManager to download and cache files in the cache directory of the app. Various settings on how long to keep a file can be changed.
It uses the cache-control http header to efficiently retrieve files.
example
var file = await DefaultCacheManager().getSingleFile(url);
How it works
By default the cached files are stored in the temporary directory of the app. This means the OS can delete the files any time.
Information about the files is stored in a database using sqflite. The file name of the database is the key of the cacheManager, that's why that has to be unique.
This cache information contains the end date till when the file is valid and the eTag to use with the http cache-control.
Currently, our app is using Room SQLite.
We need to let user to create application data backup, and export them as a single zip file.
Direct File Copy
I was wondering, is it safe, to perform direct File copy on application SQLite file to a temporary folder, for further zipping purpose? The reason I ask so is, I notice that sometimes the application database instead of appearing as single file like local-backup, it will have 2 additional files named local-backup-shm and local-backup-wal.
Read and Write to a temporary SQLite DB
Or, I should just create a temporary empty database, use Room to read application data and write to the temporary database? Then, zipping will be performed on the temporary database?
Copying the file is sufficient. That will copy the entire db.
How to parse value from .sqlite file, i n my sqlite file there are more than 1000 records now i need to retrieve all the values and need to show that in a listview, i have saved that file in to my asset folder, is there any way to do as like parsing csv file
All the suggestions are most welcome
Thanks in advance
You had database which has more than 1000 of records and it's in assets folder of application...
For that you need to copy asset database to installed app folder and then use it using SQLiteOpenHelper..
For more details with example you can take reference from here..
Ship an application with a database
I would recommend:
Save your data into SQLite, create ContentProvider to allow querying/updating data
See: http://developer.android.com/guide/topics/providers/content-providers.html
Use CursorLoader and CursorAdapter to load data from ContentProvider and bind them to your list view asynchronously
See: https://developer.android.com/training/load-data-background/setup-loader.html
The whole process seems to be overwhelmed at first with a lot of things need to be created, but once done you will get the flow.
I want to upload local sqlite database file at server but in sql format. Is it possible to directly save it in mysql supported format? The file is uploaded successfully on server but its just a flat file of sqlite db. When i open it in editplus or import it in phpmyadmin, it shows error. But when I manually export the database from sqlite manager in .sql extension, it successfully gets open in readable format in editplus. Please help me with this problem. Thanks in advance !
AFAIK you are talking about two completely different things.
Its like comparing a DB dump file to a properly exported file like an xml file with schema and data information from Oracle or MySql
When you export you get a file with or without .sql extension and it means a file with set of queries like DDL or DML create,insert etc. That may be sequentially run to execute all the commands in it and provide you with the right schema and data present in that file.
Whereas a DB file that is created via app is specific to the device and is an .sqlite file which is specific to sqlite browser and that may read it and not a set of queries only that you may open in edit-plus or a text editor.
Sqlite DB file that you find on your device is dynamically generated pages to maintain the integrity of the db.
For more info you must read,
Format of sqlite database
Sorry I don't have code but the idea is,
--Edit with algo--
Assuming you have the create commands for all tables and constraints with you , as they are not going to change most of the time.
You may use this function as a Utility to create and maintain the sql
command list for you parallel to the db you have.
void createExportCommands()
{
...
- Read all tables one by one using a `Cursor`
- Based on specific tables/columns create queries
i.e. String query="insert into "+your_table+" values("+cursor.getString(0),....+");";
- Write this data into a file called export_data.sql and keep updating it in background
}
Perhaps its not the best approach but it will solve your issue.
i need hints for SQLite; I receive in SOAP or REST format a large XML (betwen 200 and 5000 entries depending on the user, with around 30 columns) that i parse to a local SQLite db.
This operation takes too much time for the users (from 10 seconds up to 2 minutes), so i wanted to know :
Is it possible under a window server (Delphi XE2 home made server) to create the SQLite database file and send the whole file to the mobile; Then on mobile side, replace the database file with the new one (data are not modified on client side, i can replace file with no regrets ^^ ) ?
On a rooted mobile, i just can't find the SQLite database file (searched for it with esFileExplorer, /data, /dbdata, /sdcard/data... nowhere) so i just don't know where i will have to put that file in the end...
Yes, its possible.
You can download the database having latest data & replace it with current database. Find an example here of "How to use existing data base", link for sample project is also there.
EDIT:
You need to modify it according to your needs.
You can delete your existing database by using context.deleteDatabase(DATABASE_NAME);