getAssets() was added in API Level 1
getAssets() - Retrieve underlying AssetManager storage for these resources.
1. Declare an InputStream named myInputStream.
2. In the MainActivity.java file, add the below statement to the imports section
import java.io.IOException;
3. Add the code below to the onCreate method. It must be wrapped in a try/catch/finally. Change mySQLiteDatabase.db to your file name.
getAssets() - Retrieve underlying AssetManager storage for these resources.
1. Declare an InputStream named myInputStream.
2. In the MainActivity.java file, add the below statement to the imports section
import java.io.IOException;
3. Add the code below to the onCreate method. It must be wrapped in a try/catch/finally. Change mySQLiteDatabase.db to your file name.
myInputStream = this.getAssets().open("mySQLiteDatabase.db");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (myInputStream != null) {
try {
myInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
4. Compile and run!
