Answer the question
In order to leave comments, you need to log in
Where to store data before writing to the database?
Hello everyone ..
There is a lot of information and when installing the application I will write it to the database, where to store it before writing it to the database?
The choice fell on res/values -> string-array, but here's the problem, how to get this resource?
outside Activity getResources does not work..
Please tell me how to be here?
MB pass activity context and there already:
ctx.getRes... ?
Answer the question
In order to leave comments, you need to log in
Store the ready-made sqlite database in assets and copy it to /packagename/database the first time you run it, the easiest way.
Add android-sqlite-asset-helper to build.gradle:
dependencies {
......
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
}
#!/bin/sh
DATABASE=/tmp/words.db
SCRIPT_DIR=`dirname $0`
DESTINATION=$SCRIPT_DIR/../android/Slova/app/src/main/assets/databases/words.db.gz
rm -f $DATABASE
echo ".read android.sql" | sqlite3 -echo $DATABASE
perl $SCRIPT_DIR/encode-words-for-sqlite.pl < $SCRIPT_DIR/nouns.txt > /tmp/nouns-encoded.txt
perl $SCRIPT_DIR/encode-words-for-sqlite.pl < $SCRIPT_DIR/verbs.txt > /tmp/verbs-encoded.txt
echo ".import /tmp/nouns-encoded.txt words_nouns" | sqlite3 -echo $DATABASE
echo ".import /tmp/verbs-encoded.txt words_verbs" | sqlite3 -echo $DATABASE
gzip -vc $DATABASE > $DESTINATION
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question