Reputation: 113
I need to insert about 700 records(name,id) into sqlite permanently ,because app will get user's name from the database.
I think ,reading text file is a solution but not know this is the best.
Can you show me other options to insert about 700 records into database?
thanks
Upvotes: 0
Views: 102
Reputation: 209
The best practice to add multiple inserts into database shown in this video tutorial, you can watch it from 10.15
[Android Sqlite3 video tutoridal][inserting multiple values into database using fast way]
https://www.youtube.com/watch?v=dBnOn17pI7c&list=PLGLfVvz_LVvQUjiCc8lUT9aO0GsWA4uNe&index=14
Upvotes: 1
Reputation: 1786
It really depends on what you want to do and why you want to do it. That being said, text files can work. I had a similar case where I stored a few thousand items into an SQLite database. I used a text file and a CSVReader to parse the text file.
InputStream is = new ByteArrayInputStream(theContent.getBytes());
BufferedReader br = new BufferedReader(new InputStreamReader(is));
CSVReader<String[]> csvReader = new CSVReaderBuilder<String[]>(br).strategy(new CSVStrategy('\t', '\b', '#', true, true)).entryParser(new EntryParser()).build();
while ((nextLine = csvReader.readNext()) != null) {
// Do Parsing work and Store to SQLite Database
}
If you know the data won't change and want the fastest solution, then a text file is sufficient. If the data will change frequently, then you're probably going to want to access a web service to update your data. The speed of this method will be affected by the internet speed of the user.
Upvotes: 0
Reputation: 267
U have Sqlite browser in order to view sqlite database.Insert data using the browser and u can permanently use that database. Or try adding data to database using webservices.
Upvotes: 0