Skip to content

Instantly share code, notes, and snippets.

Marko Jerkić markojerkic

View GitHub Profile
View Stop.java
mediaRecorder.stop();
mediaRecorder.release();
mediaRecorder = null;
@markojerkic
markojerkic / Start.java
Created May 20, 2017
Start the recording
View Start.java
try {
mediaRecorder.prepare();
mediaRecorder.start();
} catch (IOException e) {
Log.e("LOG_TAG", "prepare() failed");
}
View MediaRecord.java
MediaRecorder mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setOutputFile(mFileName);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
View request.xml
<uses-permission android:name="android.permission.RECORD_AUDIO" />
View Delete.java
public void delete(DatabaseHelper mDbHelper, String value) {
SQLiteDatabase db = mDbHelper.getReadableDatabase();
//Where comand
String selection = FeedEntry.COLUMN_NAME1 + " LIKE ?";
//Replace the '
String[] selectionArgs = { value };
//Delete the value
db.delete(FeedEntry.TABLE_NAME, selection, selectionArgs)
}
View Update.java
public void update(DatabaseHelper mDbHelper, String value, String prevValue) {
SQLiteDatabase db = mDbHelper.getReadableDatabase();
// New value for one column
ContentValues values = new ContentValues();
values.put(FeedEntry.COLUMN_NAME1, value);
// Which row to update, based on the title
String selection = FeedEntry.COLUMN_NAME1 + " LIKE ?";
String[] selectionArgs = { prevValue };
View Put.java
public void put(DatabaseHelper mDbHelper, String value1, String value2) {
// Gets the database in write mode
SQLiteDatabase db = mDbHelper.getWritableDatabase();
//Content values store the date you want to put into the database
//Content values connect the value with the column
ContentValues values = new ContentValues();
values.put(FeedEntry.COLUMN_NAME1, value1);
values.put(FeedEntry.COLUMN_NAME1, value2);
View ArrayList.java
ArrayList list = new ArrayList<>();
while(cursor.moveToNext()) {
String column1 = cursor.getString(
cursor.getColumnIndexOrThrow(FeedEntry.COLUMN_COLUMN1));
list.add(column1);
}
cursor.close();
@markojerkic
markojerkic / Read.java
Created Apr 22, 2017
Read method of CRUD
View Read.java
public void read (DatabaseHelper mDbHelper) {
SQLiteDatabase db = mDbHelper.getReadableDatabase();
// Define which rows you want to query
String[] projection = {
FeedEntry._ID,
FeedEntry.COLUMN_NAME1,
FeedEntry.COLUMN_NAME2
};
@markojerkic
markojerkic / SubjectDbHelper.java
Created Apr 22, 2017
A sample code that shows how the SQLiteOpenHelper works
View SubjectDbHelper.java
package com.markojerkic.gradetrack.subjectData;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class SubjectDbHelper extends SQLiteOpenHelper {
private static final String SQL_CREATE_ENTRIES =
"CREATE TABLE " + SubjectFeedReaderConctact.SubjectFeedEntry.TABLE_NAME + " (" + //Creating a table named in the FeedEntery class
You can’t perform that action at this time.