Sqlite create database and table with BAT file for Android
Sqlite3 create database and table with load.bat file and fill data to table example.
- Create folder for your project: my_sqlite_project
- Open folder and create file load.bat and paste to load.bat this text and save to project folder:
sqlite3 my_database.s3db < load_text.sql
pause
- Create load_text.sql file and paste this text and save to project folder:
CREATE TABLE [android_metadata] (
[locale] TEXT
);
CREATE TABLE [my_table] (
[_id] int NULL,
[word] VARCHAR(255) NULL,
[description] VARCHAR(255) NULL
.separator ";"
.import text_file.txt my_table
- Create text_file.txt and paste this text and save it as UTF-8:
1;word1;my first word
2;word2; my second word - Download sqlite3.exe and put to project folder.
- Run BAT file load.bat and read text instruction from console
- If database created you can open and edit this with sqlite database explorer
- Copy database to Asses Android project folder
- If you want using this database in Android application on device, you have to copy this database to folder on device /data/data/com.MyPackage/databases/
396LW NO topic_id
AD
Další témata ....(Topics)
Cut, shear, clip, snip, crop a bitmap, picture, image Android example
public class ApokusActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
private static class SampleView extends View {
// CONSTRUCTOR
public SampleView(Context context) {
super(context);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
canvas.drawColor(Color.YELLOW);
// you need to insert a image flower_blue into res/drawable folder
paint.setFilterBitmap(true);
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
R.drawable.flower_blue);
Bitmap croppedBmp = Bitmap.createBitmap(bitmapOrg, 0, 0,
bitmapOrg.getWidth() / 2, bitmapOrg.getHeight());
int h = bitmapOrg.getHeight();
canvas.drawBitmap(bitmapOrg, 10, 10, paint);
canvas.drawBitmap(croppedBmp, 10, 10 + h + 10, paint);
}
}
}
public class Main extends Activity {
private TextView mTextView;
private Activity mAct;
private Intent mIntent;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
mTextView = findViewById(R.id.mTextView);
mAct = getActivity();
mIntent = getIntent();
}
}
to:
public class Main extends Fragment{
private TextView mTextView;
private FragmentActivity mFrgAct;
private Intent mIntent;
private LinearLayout mLinearLayout;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_main, null);
return root;
}
public void onViewCreated(View view, Bundle savedInstanceState) {
// you can add listener of elements here
/*Button mButton = (Button) view.findViewById(R.id.button);
mButton.setOnClickListener(this); */
mTextView = view.findViewById(R.id.mTextView);
mLinearLayout = (LinearLayout)view;
}
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mFrgAct = getActivity();
mIntent = mFrgAct.getIntent(); // Intent intent = new Intent(getActivity().getIntent());
}
}
Try reboot device.
Start device with start button on side of phone.
Screen will go to light black color.
Long press Start button for menu:
Power off
Reboot
Airplane mode
Reboot item is in same level like Start button.
Click on the screen - (Hear a click)
Now find OK button , it is under Reboot item on right side of screen.
Press OK (Hear a click)
Wait a moment.
If device to do nothing , try short press Start button (sreen will black)
and again to press Start button. If screen go to light black color,
try again find Reboot item as written above.
Start device with start button on side of phone.
Screen will go to light black color.
Long press Start button for menu:
Power off
Reboot
Airplane mode
Reboot item is in same level like Start button.
Click on the screen - (Hear a click)
Now find OK button , it is under Reboot item on right side of screen.
Press OK (Hear a click)
Wait a moment.
If device to do nothing , try short press Start button (sreen will black)
and again to press Start button. If screen go to light black color,
try again find Reboot item as written above.
Button, setOnClickListener, Intent.ACTION_VIEW, startActivity Android example.
Button mIdButtonHome = (Button)findViewById(R.id.idButtonHome);
mIdButtonHome.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent browserIntent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("//android.okhelp.cz/category/software/"));
startActivity(browserIntent);
}
});
List LinkedList Collections add sort find search Item, get searched item to string in Java example.
MainClass.java
MainClass.java
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = {"nothing", "Hello", "people"
, "bye-bye", "hello", "world!", "End" };
List<String> arrayList = new LinkedList<String>();
for(String s: arrayOfString)
arrayList.add(s);
Collections.sort(arrayList);
// foreach
for (String str: arrayList)
System.out.println(str);
Object objMin = Collections.min(arrayList);
System.out.println("Min is: " + objMin);
Object objMax = Collections.max(arrayList);
System.out.println("Max is: " + objMax);
int index = Collections.binarySearch(arrayList, "people");
System.out.println("Index of people is: " + index);
// print word on index 5
System.out.println("Index 5 is: " + arrayList.get(5));
String sItem = arrayList.get(5); // get item from index 5 to string
}
}
/*
End
Hello
bye-bye
hello
nothing
people
world!
Min is: End
Max is: world!
Index of people is: 5
Index 5 is: people
*/
Editace: 2011-09-26 20:47:35
Počet článků v kategorii: 396
Url:sqlite-create-database-and-table-with-bat-file